Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(instrumentation-fs): fix fs.exists when it's util.promisified #1222

Merged
merged 5 commits into from
Oct 10, 2022

Conversation

rauno56
Copy link
Member

@rauno56 rauno56 commented Oct 7, 2022

Which problem is this PR solving?

fs.exists has an unusual signature with the callback never returning an error.
To get around that when using util.promisify, custom promisifing function is defined.
Our instrumentation doesn't take that into account.

Fixes #1185

Short description of the changes

Added separate patcher for fs.exists that is aware of the above and define a new custom promisifying function for our patched function.

@codecov
Copy link

codecov bot commented Oct 7, 2022

Codecov Report

Merging #1222 (b34355d) into main (5da46ef) will increase coverage by 0.12%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1222      +/-   ##
==========================================
+ Coverage   96.08%   96.20%   +0.12%     
==========================================
  Files          14       15       +1     
  Lines         893      948      +55     
  Branches      191      195       +4     
==========================================
+ Hits          858      912      +54     
- Misses         35       36       +1     
Impacted Files Coverage Δ
...tapackages/auto-instrumentations-node/src/utils.ts 98.18% <0.00%> (ø)

if (fName === 'exists') {
// handling separately because of the inconsistent cb style:
// `exists` doesn't have error as the first argument, but the result
if (isWrapped(fs[fName])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need to duplicate this if. could be moved up before if (fName === 'exists') { once for all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fs.exists with util.promisify causes to unhandled rejection
3 participants